package com.cndw.kungfu.model.business;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cndw.commons.util.BlankUtils;
import com.cndw.kungfu.dao.IPlayerDao;
import com.cndw.kungfu.domain.Player;

/**
 * 玩家GM后台管理接口
 * 
 * 
 * @author <a href="mailto:whz-work@163.com">汪洪州</a>
 * 
 * @since 1.0 Create on 2011-8-2
 */
@Service
public class IPlayerManager {

	@Resource
	private IPlayerDao iPlayerDao;

	public List<Player> getPlayers(long playerId, String playerName, String accountName, int regBeginTime, int regEndTime, int loginBeginTime, int loginEndTime, int offset,
			int limit) {
		if (!BlankUtils.isBlank(playerName)) {
			playerName = "%" + playerName + "%";
		}
		if (!BlankUtils.isBlank(accountName)) {
			accountName = "%" + accountName + "%";
		}
		return iPlayerDao.getPlayers(playerId, playerName, accountName, regBeginTime, regEndTime, loginBeginTime, loginEndTime, offset, limit);
	}

	public int getPlayersCount(long playerId, String playerName, String accountName, int regBeginTime, int regEndTime, int loginBeginTime, int loginEndTime) {
		if (!BlankUtils.isBlank(playerName)) {
			playerName = "%" + playerName + "%";
		}
		if (!BlankUtils.isBlank(accountName)) {
			accountName = "%" + accountName + "%";
		}
		return iPlayerDao.getPlayersCount(playerId, playerName, accountName, regBeginTime, regEndTime, loginBeginTime, loginEndTime);
	}

	public String getOnlineCounts() {
		return iPlayerDao.getOnlineCounts();
	}

	public String getOnlineFilterCounts() {
		return iPlayerDao.getOnlineFilterCounts();
	}
	
	public Map<String, Integer> getOnLine(int scends){
		try {
			return iPlayerDao.getOnLine(scends);
		} catch (Exception e) {
			e.printStackTrace();			
		}
		return null;
	}
}
